<template>
    <div class="footer">
        <div class="row_1">
            <div class="invisible">
                <!-- 悬浮架 -->
                <Suspension></Suspension>
            </div>
        </div>
        <div class="row_2">
            <div class="cell_1">
                <input class="input" type="text" placeholder="请输入" v-model="inputMessage" @keydown.enter="sendMessage">
            </div>
            <div class="cell_2">
                <div class="button" @click="sendMessage">发送</div>
            </div>
        </div>
    </div>
</template>

<script>
import Suspension from './footer_components/Suspension.vue'

export default {
    components: {
        Suspension,
    },
    inject: ['intentManager'],
    data() {
        return {
            inputMessage: '',
        }
    },
    methods: {
        sendMessage() {
            if (this.inputMessage) {
                this.intentManager.addIntent({
                    type: 'UserMessage',
                    text: this.inputMessage,
                });
                this.inputMessage = '';
            }
        }
    }
}
</script>

<style scoped>
.footer {
    position: relative;
    width: 100%;
    height: 4em;
    overflow: visible;
    background-color: #ffffff;
}

.footer .row_1 {
    width: 100%;
    height: 0;
    overflow: visible;
}

.footer .row_2 {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    height: 100%;
}

.footer .row_2 .cell_1 {
    width: calc(100% - 4em);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer .row_2 .cell_2 {
    width: 6em;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input {
    width: 100%;
    height: 3em;
    border: none;
    outline: none;
    background-color: #f5f5f5;
    box-shadow: 0 0 1em #f5f5f5;
    border-radius: 1em;
    padding-left: 1em;
    margin-left: 1em;
    font-size: 1em;
}

.button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80%;
    height: 2em;
    border: none;
    outline: none;
    background-color: #d72618;
    color: #ffffff;
    box-shadow: 0 0 1em #f5f5f5;
    border-radius: 1em;
    cursor: pointer;
}

.invisible {
    position: relative;
    height: 0;
    overflow: visible;
}
</style>